/*
 * Teacher.java
 *
 * Created on 07 February 2007, 14:00
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package eu.expressis.eiaf.auth.infrastructure.integration.db.entity;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;

import eu.expressis.eiaf.core.infrastructure.integration.db.entity.AbstractEntity;

/**
 * Entity class Teacher
 *
 * @author Sergio
 */
@Entity
public class Teacher extends AbstractEntity {
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name="username")
    @Basic
    private User userAccount;
    
    private String rank;
    private String firstName;
    private String lastName;
    
    
    public Teacher() {
    }
    /** Creates a new instance of Teacher */
    public Teacher(String rank, String firstName, String lastName) {
        this.setRank(rank);
        this.setFirstName(firstName);
        this.setLastName(lastName);
    }
    
    
    public String getRank() {
        return rank;
    }
    
    public void setRank(String rank) {
        this.rank = rank;
    }
    
    public String getFirstName() {
        return firstName;
    }
    
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }
    
    public String getLastName() {
        return lastName;
    }
    
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
    
    public User getUserAccount() {
        return userAccount;
    }
    
    public void setUserAccount(User userAccount) {
        this.userAccount = userAccount;
    }
    
    public Long getId() {
        return id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Teacher other = (Teacher) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
    
    
}
